// pages/wattingReceiptOrderInfo/wattingReceiptOrderInfo.js
var app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        process: {
            1: "未付款",
            2: "待接单",
            3: "已接单",
            4: "生产中",
            5: "运送中",
            6: "已签收",
            7: "退款完成"
        }
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var order_id = options.order_id;
        this.setData({
            order_id:order_id
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        var that=this;
        var order_id=that.data.order_id;
        that.get_order_details(order_id)
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },
    get_order_details: function (order_id) {
        var that = this;
        var params = {};
        params['id'] = order_id;
        wx.request({
            url: app.config() + "order/orderDetail",
            data: params,
            header: {
                'content-type': 'application/json'
            },
            success: function (res) {
                var data = res.data.data;
                var order = data.order;
                // var cur_time=Date.parse(new Date())/1000+5184000;//申请售后到期时间
                order['process'] = that.data.process[order.process]
                order['pay_time'] = app.to_time(order.pay_time)
                var product_order = data.product_order;
                var process=data.process;
                that.setData({
                    order: order,
                    product_order: product_order,
                    express_number: order.express_number,
                    scan_process:process
                })
            }
        })

    },
    view_details: function (e) {
        var order_id = e.currentTarget.dataset.order_id;
        wx.navigateTo({
            url: '../../pages/customDetail/customDetail?order_id=' + order_id,
        })
    },//去申请售后
    to_customer_service: function (e) {
        var sub_order_id = e.currentTarget.dataset.sub_order_id;
        var goods_name = e.currentTarget.dataset.goods_name;
        wx.navigateTo({
            url: '../../pages/apply/apply?sub_order_id=' + sub_order_id + "&goods_name=" + goods_name,
        })
    },//去评价
    to_evaluate: function (e) {
        var sub_order_id = e.currentTarget.dataset.sub_order_id;
        var goods_name = e.currentTarget.dataset.goods_name;
        wx.navigateTo({
            url: '../../pages/evaluate/evaluate?sub_order_id=' + sub_order_id + "&goods_name=" + goods_name,
        })
    },//复制快递单号
    copy_express_number: function () {
        var that = this;
        var express_number = that.data.express_number;
        wx.setClipboardData({
            data: express_number,
            success: function (res) {
                wx.showToast({
                    title: '复制成功',
                    icon: 'success'
                })
            }
        })
    }
})